import Vue from "vue";
import VueRouter from "vue-router";
import store from "@/store";

Vue.use(VueRouter);
const router = new VueRouter({
  routes: [
    {
      path: "/",
      component: () => import("../views/home/index.vue"),
<<<<<<< HEAD

=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      children: [
        {
          path: "film",
          component: () => import("../views/home/film/index.vue"),
          children: [
            {
              name: "/content",
              path: "/content/:id",
              component: () =>
                import("../views/home/film/Information/content.vue")
            }
          ]
        },
        {
          path: "/Advisory",
          component: () => import("../views/Advisory/index.vue")
        },
        {
          path: "/volunteer",
          component: () => import("../views/volunteer/index.vue"),
          children: [
            {
              path: "/Major",
              component: () => import("../views/volunteer/Major/index.vue")
            },
            {
              path: "/Manual",
<<<<<<< HEAD
              meta: {
                isVIP: false
              },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
              component: () => import("../views/volunteer/Manual/index.vue")
            },
            {
              path: "/Intelligence",
              component: () => import("../views/volunteer/Intelligence")
            },
            {
              path: "/School",
              component: () => import("../views/volunteer/School")
            },
<<<<<<< HEAD
            {
              path: "",
              meta: {
                isVIP: false
              },
              redirect: "/Intelligence"
            }
=======
            {path: "", redirect: "/Intelligence"}
>>>>>>> 314b442cce11d658746227581b0160373004c345
          ]
        },

        {path: "", redirect: "/film"}
      ]
    },
    {
<<<<<<< HEAD
      path: "/Upload",
      component: () => import("../views/Upload")
    },
    {
      path: "/Course",
      component: () => import("../views/Course")
    },
    {
      path: "/AboutUs",
      component: () => import("../views/AboutUs")
    },
    {
      path: "/GetStudent",
      name: "/GetStudent",
      component: () => import("../views/GetStudent")
    },
    {
      path: "/Cooperation",
      component: () => import("../views/Cooperation/index.vue")
    },
    {
      path: "/RecommendMore/:show",
      name: "/RecommendMore",
      meta: {
        isVIP: false
      },
      component: () => import("../views/RecommendMore")
    },
    {
      name: "/CoreData",
      path: "/CoreData",
      component: () => import("../views/CoreData"),
      meta: {
        isVIP: false
      }
=======
      name: "/CoreData",
      path: "/CoreData",
      component: () => import("../views/CoreData")
>>>>>>> 314b442cce11d658746227581b0160373004c345
    },
    {
      name: "/RankList",
      path: "/RankList",
<<<<<<< HEAD
      meta: {
        isVIP: false
      },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/RankList")
    },
    {
      name: "/FindSchool",
      path: "/FindSchool",
      component: () => import("../views/FindSchool")
    },

    {
      name: "/ChooseSchool",
      path: "/ChooseSchool/:id/:batch/:type",
      component: () => import("../views/ChooseSchool"),
      children: [
        {
          path: "/ChooseSchool/Write",
          component: () => import("../views/ChooseSchool/Write")
        }
      ]
    },
    {
      path: "/AdvisoryDetails/:id",
      name: "/AdvisoryDetails",
<<<<<<< HEAD
      // meta: {
      //   isVIP: false
      // },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/AdvisoryDetails/index.vue")
    },
    {
      path: "/AdvisoryDetails/advisory/:id",
      name: "/AdvisoryDetails/advisory",
<<<<<<< HEAD
      meta: {
        isVIP: false
      },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/AdvisoryDetails/advisory.vue")
    },

    {
      path: "/Personal",
      component: () => import("../views/Personal/index.vue"),
      children: [
        {
          path: "/VolunteerList",
          component: () => import("../views/Personal/VolunteerList")
        },
        {
          path: "/Alternative",
          component: () => import("../views/Personal/Alternative")
        },
        {
          path: "/MyPK",
          component: () => import("../views/Personal/MyPK")
        },
        {
          path: "/Follow",
          component: () => import("../views/Personal/Follow"),
          children: [
            {
              path: "/Follow/school",
              component: () => import("../views/Personal/Follow/school.vue")
            },
            {
              path: "/Follow/major",
              component: () => import("../views/Personal/Follow/major.vue")
            },
            {path: "", redirect: "/Follow/school"}
          ]
        },
        {path: "", redirect: "/VolunteerList"}
      ]
    },
<<<<<<< HEAD

=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
    {
      name: "/PKDetails",
      path: "/PKDetails/:type",
      component: () => import("../views/PKDetails")
    },
    {
      path: "/SchoolDeatil/:userId",
      name: "/SchoolDeatil",
<<<<<<< HEAD
      meta: {
        isVIP: false
      },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/SchoolDeatil"),
      children: [
        {
          path: "/SchoolDeati/School/:userId",
          name: "/SchoolDeati/School",
<<<<<<< HEAD
=======

>>>>>>> 314b442cce11d658746227581b0160373004c345
          component: () => import("../views/SchoolDeatil/School")
        },
        {
          path: "/SchoolDeati/RecruitStudents/:userId",
          name: "/SchoolDeati/RecruitStudents",
          component: () => import("../views/SchoolDeatil/RecruitStudents")
        },
        {
          name: "/SchoolDeati/Information",
          path: "/SchoolDeati/Information/:userId",
          component: () => import("../views/SchoolDeatil/Information")
        },
        {
          path: "/SchoolDeati/Whereabouts",
          component: () => import("../views/SchoolDeatil/Whereabouts")
        },
        {path: "", redirect: "/SchoolDeati/School"}
      ]
    },
    {
      path: "/MajorDeatil",
      name: "/MajorDeatil",
<<<<<<< HEAD
      meta: {
        isVIP: false
      },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/MajorDeatil"),
      children: [
        {
          path: "/MajorDeatil/Whereabouts",
<<<<<<< HEAD
          component: () => import("../views/MajorDeatil/Whereabouts"),
          meta: {
            isVIP: false
          }
        },
        {
          path: "/MajorDeatil/Deatils",
          component: () => import("../views/MajorDeatil/Deatils"),
          meta: {
            isVIP: false
          }
        },
        {
          path: "/MajorDeatil/OpenSchool",
          component: () => import("../views/MajorDeatil/OpenSchool"),
          meta: {
            isVIP: false
          }
=======
          component: () => import("../views/MajorDeatil/Whereabouts")
        },
        {
          path: "/MajorDeatil/Deatils",
          component: () => import("../views/MajorDeatil/Deatils")
        },
        {
          path: "/MajorDeatil/OpenSchool",
          component: () => import("../views/MajorDeatil/OpenSchool")
>>>>>>> 314b442cce11d658746227581b0160373004c345
        },
        {path: "", redirect: "/MajorDeatil/Deatils"}
      ]
    },
    {
      path: "/IntelligenceList",
      component: () =>
        import("../views/volunteer/Intelligence/IntelligencedList")
    },
    {
      path: "/MyMember",
      component: () => import("../views/MyMember"),
      children: [
        {
          name: "/MyMember/Member",
          path: "/MyMember/Member/:tyle",
          component: () => import("../views/MyMember/Member")
        }
      ]
    },
    {
      path: "/VolunteerList/VolunteerDetails/:schoolId",
      name: "/VolunteerList/VolunteerDetails",
      component: () =>
        import("../views/Personal/VolunteerList/VolunteerDetails")
    },
    {
      path: "/OccupationTest/CareerPlan",
      name: "/OccupationTest/CareerPlan",
<<<<<<< HEAD
      meta: {
        isVIP: false
      },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/OccupationTest/CareerPlan")
    },
    {
      path: "/OccupationTest/TestQuestion",
      name: "/OccupationTest/TestQuestion",
<<<<<<< HEAD
      meta: {
        isVIP: false
      },
=======
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/OccupationTest/TestQuestion")
    },

    {
<<<<<<< HEAD
      path: "/OccupationTest/TextResult/:type",
      name: "/OccupationTest/TextResult",
      meta: {
        isVIP: false
      },
=======
      path: "/OccupationTest/TextResult",
      name: "/OccupationTest/TextResult",
>>>>>>> 314b442cce11d658746227581b0160373004c345
      component: () => import("../views/OccupationTest/TextResult")
    },

    {
      path: "*",
      redirect: "/film"
    }
  ]
});
<<<<<<< HEAD
// router.beforeEach((to, from, next) => {

//   // if (to.meta.isVIP) {
//   //   return next({
//   //     path: "/MyMember",
//   //     query: {
//   //       redirect: to.fullPath
//   //     }
//   //   });
//   // }

//   // next();
// });
router.afterEach((to, from) => {
  window.scrollTo(0, 0);
});

router.beforeEach(function(to, from, next) {
  {
    let userInfo = JSON.parse(localStorage.getItem("userInfo"));
    var vip = userInfo.userEntity.vip;
    // eslint-disable-next-line no-console
    console.log(vip);
    let Token = localStorage.getItem("Token");
    if (vip > 1) {
      next();
    } else {
      if (to.meta.isVIP == false) {
        next("/MyMember/Member/3");
      } else {
        next();
      }
    }
    if (Token != "") {
      next();
    } else {
      this.$router.go(0);
    }
  }
});
=======

>>>>>>> 314b442cce11d658746227581b0160373004c345
export default router;
